public class First {
    public static void main(String[] args) {
        String s = "acscxa";
        int ret = First.first(s);
        System.out.println(ret);

    }

    public static int first(String s) {
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            count[ch - 'a']++;//让下标每次从0开始
        }
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (count[ch - 'a'] == 1) {
                return i;
            }
        }
        return -1;
    }


   /* public static void main(String[] args) {
        String s = "dbpqdbpsghedb";
        int ret = First.first(s);
        System.out.println(ret);*/

}


